
package com.jk.controller;
import cn.hutool.core.util.URLUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 位佳生
 * @title: HttpRequestController
 * @projectName springboot_financial
 * @description: TODO
 * @date 2022/11/320:47
 */
@Slf4j
@RestController
@RequestMapping("http")
public class HttpRequestController {


    /**
     * @Author: binzi
     * @Description:调用机器人接口(智能机器人回复调用青云客)
     * @Date: 2022/10/24 9:41
     * @Return: java.lang.String
     **/
    @RequestMapping("aiReply")
    public  String aiReply(String content){
        String body = HttpRequest.get("http://api.qingyunke.com/api.php?key=free&appid=0&msg="+ URLUtil.encode(content))
                .execute().charset("utf-8").body();
        JSONObject jsonObject = JSONUtil.parseObj(body);
        if (jsonObject.getStr("result").equals("0")) {
            return jsonObject.getStr("content");
        }else {
            return "操作频繁！！！";
        }
    }
//

}